/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.adama.entite.modele;

import fr.adama.entite.typePerso.TypeFacturation;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.OrderBy;

/**
 *
 * @author mini-john
 */
@Entity
@Table(uniqueConstraints = @UniqueConstraint(name = "nomExistModeleFacture", columnNames = {"nom"}))
public class ModeleFacture implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "modelfacture_sequence")
    @SequenceGenerator(name = "modelfacture_sequence", sequenceName = "modelfacture_sequence")
    private Long id;

    private String nom;
    private String code;
    private String message;
    private TypeFacturation typeFacturation;

    @OneToMany(mappedBy = "modeleFacture", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @OrderBy(clause = "positionFacture")
    private List<LigneFactureModele> ligneFactureModeles;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public TypeFacturation getTypeFacturation() {
        return typeFacturation;
    }

    public void setTypeFacturation(TypeFacturation typeFacturation) {
        this.typeFacturation = typeFacturation;
    }

    public List<LigneFactureModele> getLigneFactureModeles() {
        return ligneFactureModeles;
    }

    public void setLigneFactureModeles(List<LigneFactureModele> ligneFactureModeles) {
        this.ligneFactureModeles = ligneFactureModeles;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ModeleFacture)) {
            return false;
        }
        ModeleFacture other = (ModeleFacture) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.adama.entite.modele.FactureModele[ id=" + id + " ]";
    }

}
